'use strict';

const Service = require('egg').Service;

class CommonService extends Service {
  async login(query) {
    const { ctx } = this;
    // 在当前数据库中验证此用户思否存在
        const result = await ctx.model.Users.findOne({
          where: {
            userName: query.userName
          },
          include:[
            {
              model: ctx.model['Roles'],
              as: 'roles'
            }
          ] 
        });
        return result;
  }

}

module.exports = CommonService;
